package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallGoodsProduct;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallGoodsProductMapper {
    @Delete({
        "delete from haogoumall_goods_product",
        "where goods_product_id = #{goodsProductId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer goodsProductId);

    @Insert({
        "insert into haogoumall_goods_product (goods_product_id, goods_id, ",
        "goods_product_specifications, goods_product_price, ",
        "goods_product_number, goods_product_url, ",
        "goods_product_add_time, goods_product_update_time, ",
        "goods_product_deleted)",
        "values (#{goodsProductId,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}, ",
        "#{goodsProductSpecifications,jdbcType=VARCHAR}, #{goodsProductPrice,jdbcType=DECIMAL}, ",
        "#{goodsProductNumber,jdbcType=INTEGER}, #{goodsProductUrl,jdbcType=VARCHAR}, ",
        "#{goodsProductAddTime,jdbcType=TIMESTAMP}, #{goodsProductUpdateTime,jdbcType=TIMESTAMP}, ",
        "#{goodsProductDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallGoodsProduct record);

    @InsertProvider(type=HaogoumallGoodsProductSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallGoodsProduct record);

    @Select({
        "select",
        "goods_product_id, goods_id, goods_product_specifications, goods_product_price, ",
        "goods_product_number, goods_product_url, goods_product_add_time, goods_product_update_time, ",
        "goods_product_deleted",
        "from haogoumall_goods_product",
        "where goods_product_id = #{goodsProductId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="goods_product_id", property="goodsProductId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="goods_id", property="goodsId", jdbcType=JdbcType.INTEGER),
        @Result(column="goods_product_specifications", property="goodsProductSpecifications", jdbcType=JdbcType.VARCHAR),
        @Result(column="goods_product_price", property="goodsProductPrice", jdbcType=JdbcType.DECIMAL),
        @Result(column="goods_product_number", property="goodsProductNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="goods_product_url", property="goodsProductUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="goods_product_add_time", property="goodsProductAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="goods_product_update_time", property="goodsProductUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="goods_product_deleted", property="goodsProductDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallGoodsProduct selectByPrimaryKey(Integer goodsProductId);

    @UpdateProvider(type=HaogoumallGoodsProductSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallGoodsProduct record);

    @Update({
        "update haogoumall_goods_product",
        "set goods_id = #{goodsId,jdbcType=INTEGER},",
          "goods_product_specifications = #{goodsProductSpecifications,jdbcType=VARCHAR},",
          "goods_product_price = #{goodsProductPrice,jdbcType=DECIMAL},",
          "goods_product_number = #{goodsProductNumber,jdbcType=INTEGER},",
          "goods_product_url = #{goodsProductUrl,jdbcType=VARCHAR},",
          "goods_product_add_time = #{goodsProductAddTime,jdbcType=TIMESTAMP},",
          "goods_product_update_time = #{goodsProductUpdateTime,jdbcType=TIMESTAMP},",
          "goods_product_deleted = #{goodsProductDeleted,jdbcType=BIT}",
        "where goods_product_id = #{goodsProductId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallGoodsProduct record);
}